package org.teremail.server;

import org.teremail.client.MailService;
import org.teremail.client.MessageSummary;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class MockMailServiceImpl extends RemoteServiceServlet implements
        MailService {

    private static final long serialVersionUID = 1L;

    public String[] getFolders(String mailbox) {
        return new String[] { "INBOX", "Drafts", "Sent", "Trash" };
    }

    public MessageSummary[] getMessageSummaries(String mailbox, String folder) throws Exception {
        
        return new MessageSummary[] {
            new MessageSummary(1, "bart@example.com", "Hello Lisa", "2008/02/21 16:30:00"),
            new MessageSummary(2, "lisa@example.com", "Hello Bart", "2008/02/23 16:30:00"),
            new MessageSummary(3, "foo@example.com", "WTF! This code is CRAP!", "2008/02/21 16:30:00"),
            new MessageSummary(4, "homer@example.com", "D'oh", "2008/01/21 16:34:00"),
        };
    }
    
    public String getMessage(String mailbox, String folder, int uid) {
        switch (uid) {
        case 1: 
            return "Hi Lisa,\r\n" +
                    "\r\n" +
                    "How are you doing today?\r\n";
        case 2:
            return "> Hi Lisa,\r\n" +
                    ">\r\n" +
                    "> How are tou doing today?\r\n" +
                    "\r\n" +
                    "Not too bad.\r\n";
        case 3:
            return "Check out the code from this site";
        case 4:
            return "D'oh";
        default:
            return "Unknown uid: " + uid;
        }
    }

}
